  
  --get the addon namespace
  local addon, ns = ...
  
  --get the config values
  local LabelUI = ns.LabelUI
  local point = LabelUI.point
local toc = LabelUI.toc
  local cfg = ns.cfg

local function Init()
  local barcfg = cfg.bars.stancebar
    local num = NUM_STANCE_SLOTS
    
    local bar = CreateFrame("Frame","rABS_StanceBar",UIParent, "SecureHandlerStateTemplate")
    bar:SetWidth(barcfg.buttonsize*num+barcfg.buttonspacing*(num-1))
    bar:SetHeight(barcfg.buttonsize)
    bar:SetPoint(barcfg.pos.a1,point(barcfg.pos.af),barcfg.pos.a2,barcfg.pos.x,barcfg.pos.y)
    bar:SetHitRectInsets(-cfg.background.inset2, -cfg.background.inset2, -cfg.background.inset2, -cfg.background.inset2)  
    bar:SetScale(barcfg.barscale)
  
    StanceBarFrame:SetParent(bar)
    StanceBarFrame:EnableMouse(false)
    
    for i=1, num do
      local button = _G["StanceButton"..i]
      button:SetSize(barcfg.buttonsize, barcfg.buttonsize)
      button:ClearAllPoints()
      if i == 1 then
        button:SetPoint("BOTTOMLEFT", bar, 0,0)
      else
        local previous = _G["StanceButton"..i-1]  
	if barcfg.sortpoint == "top" then    
        	button:SetPoint("BOTTOM", previous, "TOP", 0, barcfg.buttonspacing)
	else
        	button:SetPoint("LEFT", previous, "RIGHT", barcfg.buttonspacing, 0)	
	end
      end
    end
    local function rABS_MoveShapeshift()
      StanceButton1:SetPoint("BOTTOMLEFT", bar, 0,0)
    end
    --hooksecurefunc("StanceBar_Update", rABS_MoveShapeshift)
end
LabelUI:AddInit(Init, "StanceBar")